package com.loongtech.bi.support;

import com.loongtech.core.util.Utils;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;

@FacesConverter("passwordConverter")
public class PasswordCredentialConverter implements Converter {

    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        return Utils.md5(value);
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        String c = (String) value;
        return value == null ? null : c;
    }

}